package com.eol.common.config;

import lombok.*;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * Created with IntelliJ IDEA.
 * User: liulinhui
 * Date: 8/8/19
 * Time: 2:13 AM
 * Description: SystemPropertiesConfig
 */
@ConfigurationProperties(prefix = "system.config")
@Component(value = "SystemPropertiesConfig")
@Data
@Builder
@ToString
public class SystemPropertiesConfig {

    private final AliYunOss aliYunOss = new AliYunOss();
    private final AliYunSms aliYunSms = new AliYunSms();
    private final Jwt jwt = new Jwt();
    private final Swagger swagger = new Swagger();
    private final AdminConfig adminConfig = new AdminConfig();
    private final Geo geo = new Geo();
    private final WxMp wxMp = new WxMp();

    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    @ToString
    public static class Geo {
        private String key;
    }

    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    @ToString
    public static class WxMp {
        private String appId;
        private String appSecret;
    }

    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    @ToString
    public static class AliYunOss {
        private boolean useOss;
        private String filesUploadPath;
        private String filesUploadPathBaseUrl;
        private String host;
        private String endpoint;
        private String accessKeyId;
        private String accessKeySecret;
        private String bucketName;
        private long oss_max_size;
        private int oss_expire;
        private String baseFilePrefix;
    }

    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    @ToString
    public static class AliYunSms {
        private String accessKeyId;
        private String accessKeySecret;
        private String signName;
        private long expireTime;
    }

    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    @ToString
    public static class Jwt {
        private String secret;
        private long expiration;
        private String priKeyPath;
        private String pubKeyPath;
    }

    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    @ToString
    public static class Swagger {
        private boolean enabled;
        private String headerToken;
    }

    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    @ToString
    public static class AdminConfig {
        private String headerToken;
        private String online;
        private String codeKey;
    }
}
